﻿using System.Data;
using Core.Library;

namespace DataObject.Order
{
    public class OrderController
    {
        public static DataTable GetListSearch(int customerId, int status, int pageIndex, int pageSize, ref int totalRecords)
        {
            return OrderDAL.GetListSearch(customerId, status, pageIndex, pageSize, ref totalRecords);
        }

        public static OrderObject Order_GetById(int orderId)
        {
            return ObjectHelper.FillObject<OrderObject>(OrderDAL.Order_GetById(orderId));
        }

        public static int Order_Create(OrderObject o)
        {
            return OrderDAL.Order_Create(o);
        }

        public static void Order_Delete(int orderId)
        {
            OrderDAL.Order_Delete(orderId);
        }

        public static void Order_Update_Status(int orderId, int status)
        {
            OrderDAL.Order_Update_Status(orderId, status);
        }

        public static void Order_Update_Note(int orderId, string note)
        {
            OrderDAL.Order_Update_Note(orderId, note);
        }

        public static int Order_GetStatistic(int status)
        {
            return OrderDAL.Order_GetStatistic(status);
        }

        public static string GetOrderStatusName(int status)
        {
            switch (status)
            {
                case 1:
                    return "Đặt hàng";
                case 2:
                    return "Hoàn thành";
                case 4:
                    return "Đã xóa";
            }
            return "";
        }
    }
}
